#!/bin/sh
dir=/var/tmp/android_pkg/
rm -rf $dir
mkdir -p $dir/tmp
cp ./*.sh $dir/
cd $dir
rsync -a ~/android/ tmp
cd tmp 
rm -rf .git*
sed 's#^\s*sdk.dir\s*=.*$#sdk.dir=/home/nick/bin/adt-bundle-linux-x86_64-20140702/sdk/#' -i project.properties
sed 's/^\s*#.*//' -i channels.properties 
ant clean
rm app-release/*.apk
cd ..
awk -F'=' '/market_channels/{print $2}' tmp/channels.properties | tr , "\n" | xargs -P 6 -Ixx ./channel.sh xx

ver=`awk -F'=' '/app_version/{print $2}' tmp/channels.properties`

rm -rf tmp

tar -vc *.apk | xz -z9 > doufu-android-{$ver}.tar.xz
